# Copyright (C) 2023 THL A29 Limited, a Tencent company. All rights reserved.
#
# Licensed under the BSD 3-Clause License (the "License"); you may not use this
# file except in compliance with the License. You may obtain a copy of the
# License at
#
# https://opensource.org/licenses/BSD-3-Clause
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
# WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
# License for the specific language governing permissions and limitations under
# the License.

cc_library(
    name = "stream_connection",
    hdrs = ["stream_connection.h"],
    visibility = ["//visibility:public"],
    deps = [
        "//flare/base:buffer",
    ],
)

cc_library(
    name = "datagram_transceiver",
    hdrs = ["datagram_transceiver.h"],
    visibility = ["//visibility:public"],
    deps = [
        "//flare/base:buffer",
        "//flare/base/net:endpoint",
    ],
)

cc_library(
    name = "acceptor",
    hdrs = ["acceptor.h"],
    visibility = ["//visibility:public"],
)

cc_library(
    name = "io_basic",
    srcs = [
        "descriptor.cc",
        "event_loop.cc",
        "//flare/io/detail:event_loop_notifier.cc",
        "//flare/io/detail:event_loop_notifier.h",
        "//flare/io/detail:watchdog.cc",
        "//flare/io/detail:watchdog.h",
    ],
    hdrs = [
        "descriptor.h",
        "event_loop.h",
    ],
    visibility = ["//visibility:public"],
    deps = [
        "//flare/base:align",
        "//flare/base:chrono",
        "//flare/base:deferred",
        "//flare/base:delayed_init",
        "//flare/base:enum",
        "//flare/base:exposed_var",
        "//flare/base:function",
        "//flare/base:handle",
        "//flare/base:likely",
        "//flare/base:logging",
        "//flare/base:maybe_owning",
        "//flare/base:random",
        "//flare/base:ref_ptr",
        "//flare/base:string",
        "//flare/base:tsc",
        "//flare/base/internal:memory_barrier",
        "//flare/base/internal:test_prod",
        "//flare/base/net:endpoint",
        "//flare/base/thread:latch",
        "//flare/fiber",
        "//flare/io/detail:eintr_safe",
        "//flare/io/detail:timed_call",
        "//flare/io/util:rate_limiter",
        "//flare/io/util:socket",
        "//flare/io/util:stream_io",
        "@com_github_gflags_gflags//:gflags",
    ],
)

cc_test(
    name = "descriptor_test",
    srcs = ["descriptor_test.cc"],
    deps = [
        ":io_basic",
        "//flare/base:random",
        "//flare/fiber",
        "//flare/testing:endpoint",
        "//flare/testing:main",
    ],
)

cc_test(
    name = "event_loop_test",
    srcs = ["event_loop_test.cc"],
    deps = [
        ":io_basic",
        "//flare/testing:main",
    ],
)
